
import sys, os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))

from AppDB import AppDB 
from AppStoreConnect import OpenExchangeRates
from datetime import datetime, timedelta

if __name__ == "__main__":
    start_date = datetime(2024, 4, 15)
    end_date = datetime(2024, 5, 6)
    
    app_db = AppDB()
    
    oer = OpenExchangeRates(app_id="587a75de82be47da981c67ac703ef118")
    current_date = start_date
    
    while current_date <= end_date:
        rates = oer.get_exchange_rates_on(current_date)
        app_db.add_exchange_rates(current_date, rates)
        current_date += timedelta(days=10)
        
    print("Done")
    